package ejb.casacentral.jms;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import ejb.casacentral.service.FachadaSession;

/**
 * Message-Driven Bean implementation class for: Reciver
 * 
 */
@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
		@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/recibirSolCompraQueue") })
public class SolicitudesJMS implements MessageListener {

	
	@EJB
	private FachadaSession fachadaSession;
	
	
	public SolicitudesJMS() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see MessageListener#onMessage(Message)
	 */
	public void onMessage(Message message) {
		if (message instanceof TextMessage) {
			TextMessage texto = (TextMessage) message;

				try {
					fachadaSession.generarOrdenesDeCompra(texto.getText());
				} catch (JMSException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

		}

	}

}
